<template>
	<view>
		<view class="page-body">
			<view class="page-section page-section-gap">
				<!-- :markers="markers" -->
				<map style="width: 100%; height: 300px;" :markers="markers" :latitude="latitude" :longitude="longitude" @tap='a1'
					clickable="true" scale='18' enable-building=true>
				</map>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				longitude: 0, // 经度
				latitude: 0, // 纬度
				area: '', //详细地址
				markers: [], // 标记点数组
				id: 0, // 使用 marker点击事件 需要填写id
				title: 'map',
			}
		},
		onLoad() {
			// uniapp自带地图定位
			this.getLocation1()
			this.set()
		},
		methods: {
			a1(res) {
				console.log(res)
				let _this = this
				this.longitude = res.detail.longitude
				this.latitude = res.detail.latitude
				this.latitude = res.detail.latitude
				uni.$emit('updates', {
					longitude: _this.longitude,
					latitude: _this.latitude,
					area: '1'
				})
				this.reverseGeocode()
				// uni.navigateBack({
				// 	delta: 1
				// })
			},
			// 测试地图方法
			set(){
				
			},
			getLocation1() {
				let _this = this
				uni.getLocation({
					type: 'gcj02',
					isHighAccuracy: true,
					success: (res) => {
						this.longitude = res.longitude
						this.latitude = res.latitude
						// 添加标记点
						_this.markers = [{
							id: 1,
							latitude: res.latitude,
							longitude: res.longitude,
							title: '当前位置'
						}]
					}
				})
			},
		}
	}
</script>

<style>

</style>